//
//  LSZAddMusicCollectionViewCell.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/21.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZAddMusicCollectionViewCell.h"

@implementation LSZAddMusicCollectionViewCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView * view = [[UIView alloc]init];
        view.backgroundColor = RGBColor(243, 244, 246);
        [self addSubview:view];

        self.imageViewIcon = [[UIImageView alloc]init];
        [view addSubview:self.imageViewIcon];

        self.imageViewPlayer = [[UIImageView alloc]init];
        self.imageViewPlayer.image = [UIImage imageNamed:@"装饰_播放"];
        [self.imageViewIcon addSubview:self.imageViewPlayer];
        [self.imageViewIcon bringSubviewToFront:self.imageViewPlayer];

        self.labelTitle = [[UILabel alloc]init];
        self.labelTitle.textColor = titleColorLSZ;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelTitle font:13.5];
        [view addSubview:self.labelTitle];

        self.labelAuthor = [[UILabel alloc]init];
        self.labelAuthor.textColor = lightColor;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelAuthor font:12.5];
        [view addSubview:self.labelAuthor];

        CGFloat heightA = [LSZSpecialPackaging initWithReturnsthesizeOf:60 :5];
        CGFloat heightB = [LSZSpecialPackaging initWithReturnsthesizeOf:50 :5];
        view.frame = CGRectMake(heightA, 0, ScreenWidth-10-heightA, heightB);

        self.imageViewIcon.frame = CGRectMake(5, 5,view.frame.size.height-10, view.frame.size.height-10);
        self.imageViewPlayer.frame = CGRectMake((self.imageViewIcon.frame.size.width-20)/2, (self.imageViewIcon.frame.size.width-20)/2, 20, 20);
        CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:18 :2];
        self.labelTitle.frame = CGRectMake(CGRectGetMaxX(self.imageViewIcon.frame)+10, CGRectGetMinY(self.imageViewIcon.frame),view.frame.size.width-CGRectGetMaxX(self.imageViewIcon.frame)-20, height);
        self.labelAuthor.frame = CGRectMake(CGRectGetMinX(self.labelTitle.frame), CGRectGetMaxY(self.imageViewIcon.frame)-20, view.frame.size.width-CGRectGetMaxX(self.imageViewIcon.frame)-20, 20);
    }
    return self;
}
-(void)setAllDynamicListsMg:(LSZAllDynamicListsMg *)AllDynamicListsMg
{
    [self.imageViewIcon sd_setImageWithURL:[NSURL URLWithString:AllDynamicListsMg.resources_image] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    if([AllDynamicListsMg.type isEqualToString:@"2"]){
        self.imageViewPlayer.hidden = NO;
        self.labelAuthor.hidden = NO;
        self.labelTitle.text = AllDynamicListsMg.resources_name;
        CGRect rect = self.labelTitle.frame;
        rect.origin.y = CGRectGetMinY(self.imageViewIcon.frame);
        self.labelTitle.frame = rect;
        self.labelAuthor.text = AllDynamicListsMg.resources_artist_name;
    }else if([AllDynamicListsMg.type isEqualToString:@"1"]){
        self.imageViewPlayer.hidden = YES;
        self.labelAuthor.hidden = NO;
        self.labelTitle.text = [NSString stringWithFormat:@"专辑:%@",AllDynamicListsMg.resources_name];
        self.labelAuthor.text = AllDynamicListsMg.resources_artist_name;

        CGRect rect = self.labelTitle.frame;
        rect.origin.y = CGRectGetMinY(self.imageViewIcon.frame);
        self.labelTitle.frame = rect;
    }
    else{
        self.imageViewPlayer.hidden = YES;
         CGRect rect = self.labelTitle.frame;
        rect.origin.y = CGRectGetMinY(self.imageViewIcon.frame)+(self.imageViewIcon.frame.size.height-self.labelTitle.frame.size.height)/2;
        self.labelTitle.frame = rect;
        self.labelTitle.text = [NSString stringWithFormat:@"歌手:%@",AllDynamicListsMg.resources_name];
        self.labelAuthor.hidden = YES;
    }
}
@end
